////////////////////////////////////////////////
// DESCRIPTION:
//
// Legal Notices:
//    Copyright (C) 2003, Entelechy Software Consulting
//    ALL RIGHTS RESERVED
//
//    This file, software, or program is supplied under the terms of a
//    license agreement and/or nondisclosure agreement with Entelechy
//    Consulting and may not be copied or disclosed except in
//    accordance with the terms of that agreement.  This file, software,
//    or program contains copyrighted material and/or trade secret
//    information of Entelechy Consulting, and must be treated as such.
//    Entelechy reserves all rights in this material, except as the license
//    agreement or nondisclosure agreement specifically indicate.
//
//    All rights reserved.  No part of this program or publication
//    may be reproduced, transmitted, transcribed, stored in a
//    retrieval system, or translated into any language or computer
//    language, in any form or by any means, electronic, mechanical,
//    magnetic, optical, chemical, manual, or otherwise, without
//    the prior written permission of Entelechy Consulting.
//
// Disclaimer:
//    Entelechy Consulting makes no warranty of any kind regarding
//    this code.  This code is provided on an "As Is" basis and
//    Entelechy Consulting will not provide any support assistance,
//    installation, training or other services.
//    Entelechy Consulting does not provide any updates, enhancements
//    or extensions. Entelechy Consulting specifically disclaims any
//    warranty of merchantability, non-infringement, fitness for any
//    particular purpose, or any other warranty.
//
//    Entelechy Consulting disclaims all liability, including liability
//    for infringement of any proprietary rights, relating to use of the
//    code. No license, express or implied, by estoppel or otherwise,
//    to any intellectual property rights is granted herein.
//
// Usage:
//    CSCRIPT /nologo GenExportDefFromLib.js <LIBRARYNAME>
//
//    Parses stdin for lines starting with /EXPORT: and converts
//    each such line to an appropriate DEF file EXPORTS Entry
//	  Typically the input to this comes from the filtered output
//    of dumpbin as follows:
//    	dumpbin /directives MYDLL_lib.lib | find "/EXPORT:" | CSCRIPT /nologo GenExportDEFfromlib.js MYDLL>MYDLL.DEF
//
var stdin = WScript.StdIn;
var stdout = WScript.StdOut;

stdout.WriteLine("LIBRARY " + WScript.Arguments(0) + "\n\nEXPORTS\n");
while (!stdin.AtEndOfStream)
{
     var reExport = new RegExp("\s*/EXPORT:"); 
     var reData = new RegExp(",DATA");
     
     var str = stdin.ReadLine();
     if(-1!=str.indexOf("/EXPORT:"))
		stdout.WriteLine(str.replace(reExport,"    ").replace(reData," DATA"));
}